import Vue from "vue"
import VueRouter from "vue-router"

Vue.use(VueRouter)

const routes = [
    //首页
    {
        path: "/home",
        name: "Home",
        component: () => import("../views/Home.vue")
    },
    //默认
    {
        path: "/",
        redirect: '/home'

    },
    //购物车
    {
        path: "/cart",
        name: "Cart",
        component: () => import("../views/Cart.vue")
    },
    //我的
    {
        path: "/my",
        name: "My",
        component: () => import("../views/My.vue")
    },
    //分类
    {
        path: "/list",
        name: "List",
        component: () => import("../views/List.vue")
    },
    //搜索
    {
        path: "/search",
        name: "Search",
        children: [
            {
                path: "/",
                name: "Index",
                component: () => import("../views/search/Search-index.vue")
            },
            {
                path: "/searchList",
                name: "SearchList",
                component: () => import("../views/search/Search-list.vue")
            }
        ],
        component: () => import("../views/Search.vue")
    },
    //商品详细
    {
        path: "/detail",
        name: "Detail",
        meta: {
            keepAlice: false,//此组件不需要被缓存
        },
        component: () => import("../views/Detail.vue")
    },
    //登录界面
    {
        path: "/login",
        name: "Login",
        component: () =>
            import("../views/login/Login.vue"),
    },
    //用户登录界面
    {
        path: "/userLogin",
        name: "UserLogin",
        component: () =>
            import("../views/login/UserLogin.vue"),
    },

    {
        path: "/register",
        name: "Register",
        component: () =>
            import("../views/login/Register.vue"),
    },
    {
        path: "/recovery",
        name: "Recovery",
        children: [
            {
                path: "/",
                name: "index",
                component: () =>
                    import("../views/recovery/RecoveryIndex.vue"),
            },
            {
                path: "btn",
                name: "btn",
                component: () =>
                    import("../views/recovery/RecoveryBtn.vue"),
            }
        ],
        component: () =>
            import("../views/Search.vue"),
    },
    {
        path: "/order",
        name: "Order",
        component: () =>
            import("../views/Order.vue"),
    },

    // 地址管理
    {
        path: "/path",
        name: "Path",
        children: [
            {
                path: "/",
                name: "pathIndex",
                component: () =>
                    import("../views/path/Path-Index.vue"),
            },
            {
                path: "path-list",
                name: "path-list",
                component: () =>
                    import("../views/path/Path-List.vue"),
            },
        ],
        component: () =>
            import("../views/Path.vue"),
    },

    //   支付后
    {
        path: "/payment",
        name: "Payment",
        component: () =>
            import("../views/Payment.vue"),
    },
]

const router = new VueRouter({
    mode: "history",
    base: process.env.BASE_URL,
    routes,
})

export default router